<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="账号">
        <el-input disabled v-model="form.username" placeholder="请输入登录账号"/>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" min="6" v-model="form.password" placeholder="登录密码"/>
      </el-form-item>
      <el-form-item label="确认密码">
        <el-input type="password" min="6" v-model="form.password1" placeholder="请输入确认密码"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import api from '@/api/basic'
import { email } from 'mockjs/src/mock/random/web'

export default {
  components: {},
  data() {
    return {

      form: {
        id: 0,
        username: '',
        password: '',
        password1: ''
      }
    }
  },

  mounted() {
    this.getData()
  },

  methods: {
    getData() {
      api.info().then((res) => {
        this.form = res.data
      })
    },
    onSubmit() {
      if (!this.form.password){
        this.$message({
          type: 'error',
          message: '请输入密码'
        })
        return
      }
      if (this.form.password !== this.form.password1){
        this.$message({
          type: 'error',
          message: '两次密码不一致'
        })
        return
      }
      this.$confirm('确定修改密码？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        api.update_pwd(this.form).then((res) => {
          this.$message({
            type: 'success',
            message: res.msg
          })
          // eslint-disable-next-line handle-callback-err
        }).catch((error) => {

        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    }
  }
}
</script>

<style scoped>
.line {
  text-align: center;
}

.editor-content {
  margin-top: 20px;
}

.article-textarea ::v-deep {

textarea {
  padding-right: 40px;
  resize: none;
  border: none;
  border-radius: 0px;
  border-bottom: 1px solid #bfcbd9;
}

}
</style>

